<?php
define('ipos',true);
require_once('./include/config.php');
// [Mod] Multi Server
for ($i=1; $i<=m_get_config('total_server_media'); $i++) {
	$movieFolder[$i] = m_get_config('server_url_'.$i).'/'.m_get_config('server_folder_'.$i);
}
// [Mod] Multi Server
$ipid			=	intval($_GET['ipid']);
$play	 		=	$db->database("epname,epurl,phimid,epsub,epdemo,server","ep","epid = '$ipid'");
$cookieMovie	=	_GETCOOKIE("play_".$play[0][2]);
// kiểm tra tài khoản
if($cookieMovie == md5($_SESSION['ipos_userid']) || $_SESSION['ipos_usergroup']!=0 || GOLD_OPEN == '0') {
	if ($play[0][5])
		$url 	= 	$movieFolder[$play[0][5]].'/'.$play[0][1];
	else
		$url	=	$play[0][1];
}else {
	if ($play[0][5])
		$url 	= 	$movieFolder[$play[0][5]].'/'.$play[0][1];
	else
		$url	=	$play[0][4];
}
// sub phim
$sub		=	$play[0][3];
if($sub) {
	$code	=	"<captions.file>".MAIN_URL."/$sub</captions.file>";
}
// provider
if (!$url) $url = 'http://www.youtube.com/watch?v=0BNk1CjJa10';
if((preg_match('#rtmp://([^/]+)#',$url)) || (preg_match('#rtmpe://([^/]+)#',$url))) {
	$provider	=	"<jwplayer:provider>rtmp</jwplayer:provider><jwplayer:streamer>".$movieFolder[$play[0][5]]."/</jwplayer:streamer>	
					<jwplayer:file>".$play[0][4]."</jwplayer:file>";	
}else {
	$provider	=	"<location>".$url."</location>";	
}
// xml
header("Content-Type: text/xml; charset=utf-8");
$xml	=	"<playlist xmlns='http://xspf.org/ns/0/'><trackList><track>";
$xml	.=	"<title>".$play[0][0]."</title>".$provider.$code."</track>";
$xml	.=	"</trackList></playlist>";
echo $xml;
exit();
?>